var  express = require('express');
var app = express();
var multer = require('multer');
app.use(express.static('public'));

var uploadPath = './public/upload';
let storage = multer.diskStorage({
	destination(req, file, cb) {
		cb(null, uploadPath);
	},
	filename(req, file, cb) {
		cb(null, Date.now() + '-' + file.originalname);
	},
});

const upload = multer({ storage });

app.post('/upload', upload.array('multiFile'), (req, res) => {
  if (req.files) {
    res.json({err:1,data:`${req.files.length}个文件上传完成`})
  }else {
    res.json({ err: 0, data: `${req.files.length}个文件上传失败` });
  }
});
app.listen(5555, (req, res) => {
	console.log('node running');
});
